<?php 
/**
 * 订单控制器
 */
class OrderController extends AuthController{
    /**
     * 
     */
    private $model;
	
	public function __auto(){
	    $this->model = K('Order');
	}
	
	
	/**
	 * 首页
	 */
    public function index(){
       	$data = $this->model->all();
		$Gdata = M()->join('__jp_order__ o JOIN __order_list__ ol ON o.oid=ol.order_oid JOIN __goods__ g ON ol.goods_gid=g.gid')->all();
		$order = array();
		foreach ($Gdata as $k => $v) {
			$order[$v['oid']]['oid']=$v['oid'];
			$order[$v['oid']]['number']=$v['number'];
			$order[$v['oid']]['consignee']=$v['consignee'];
			$order[$v['oid']]['address']=$v['address'];
			$order[$v['oid']]['total']=$v['total'];
			$order[$v['oid']]['time']=$v['time'];
			$order[$v['oid']]['status']=$v['status'];
			$order[$v['oid']]['list'][]=$v;
		}
		//分配数据
		$this->assign('order',$order);
        $this->display(); 
    }
	
	/**
	 * 发货
	 */
	public function release(){
	    $oid = Q('get.oid',0,'intval');
		//删除
		$this->model->where("oid={$oid}")->update(array('status'=>'已发货'));
		$this->success('发货成功',U('index'));
	}
	
	/**
	 * 删除订单
	 */
	public function del(){
	    $oid = Q('get.oid',0,'intval');
		//删除
		$this->model->where("oid={$oid}")->delete();
		//1.提示信息 2.跳转地址 3.跳转时间
		$this->success('删除成功',U('index'));
	}
	
	
	
	
	
	
	
	
 }
 
 
 
 
 
 
 
 
 
 
 



 ?>